package com.imooc.sell.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Description:
 * 微信
 *
 * @author zzy
 * @create 2017-09-13 11:56
 */
@Slf4j
@RestController
@RequestMapping("/weixin")
public class WexinController {
    @GetMapping("/auth")
    public void auth(@RequestParam("code") String code) {
        log.info("进入auth方法。。。");
        log.info("code={}", code);

        //返回json
        String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxf884e775db343f62&secret=f0ce2fab30466ab0293390fdabc1c566&code=" + code + "&grant_type=authorization_code";
        RestTemplate restTemplate = new RestTemplate();
        //获取返回json
        String response = restTemplate.getForObject(url, String.class);
        log.info("response={}", response);

    }
}